package xdivers;

import java.awt.Dimension;

import modele.Point;

public class Outils {
	
	public static Point RealToAdapted(Point real, Dimension d)
	{
		int width = (int) d.getWidth();
		int height = (int) d.getHeight();
		
		int realX=real.getX();
		int realY=real.getY();
		int adaptedX = realX - width/2;
		int adaptedY = - (realY - height/2);
		Point adapted = new Point(adaptedX,adaptedY,real.getCouleur());
		return adapted;
	}
	
	public static Point AdaptedToReal(Point adapted, Dimension d)
	{
		int width = (int) d.getWidth();
		int height = (int) d.getHeight();
		
		int adaptedX = adapted.getX();
		int adaptedY = adapted.getY();
		
		int realX= adaptedX + width/2;
		int realY= -(adaptedY) + height/2;
		Point real = new Point(realX,realY,adapted.getCouleur());
		return real;
	}
	
	public static Point DimensionToOrigine(Dimension d)
	{
		int x = (int) d.getWidth()/2;
		int y = (int) d.getHeight()/2;
		Point origine = new Point(x,y);
		return origine;
	}

}
